package com.example.springbootdatamock.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.springbootdatamock.bean.ProvinceStat;
import org.apache.ibatis.annotations.*;

import java.math.BigDecimal;
import java.util.List;

@Mapper
@DS("ck")
public interface HBaseMapperToCk {
//  @Update({"CREATE TABLE IF NOT EXISTS ditohbase (saletime TIME NOT NULL,brand VARCHAR NOT NULL,province VARCHAR ,orderCount INTEGER,saleamount DECIMAL(16,2)CONSTRAINT my_pk PRIMARY KEY (saletime, brand))COLUMN_ENCODED_BYTES = 0"})
  @Update({"CREATE TABLE IF NOT EXISTS ditohbase (saletime DateTime,brand String,province String ,orderCount Int32,saleamount Decimal64(2),dt String )engine = SummingMergeTree(saleamount)partition by (dt) order by (brand);"})
  void createTable();
  
  @Insert({"insert into ditohbase values(#{st},#{brand},#{prov},#{oc},#{sm},#{dt})"})
  void insertData(@Param("st") String paramString1, @Param("brand") String paramString2, @Param("prov") String paramString3, @Param("oc") Integer paramInteger, @Param("sm") BigDecimal paramBigDecimal,@Param("dt") String paramString4);
  
  @Select({"select  province , sum(ordercount) totalOrderCount , sum(saleamount) saleAmount    from ditohbase     where substr(to_char(saletime),1,10) = #{date}     group by province"})
  List<ProvinceStat> queryProvinceStatToday(String paramString);
}


